
a=['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
lst=[]
b=input()
b=b.split()
s=''
q1=0
k=0
q2=0
for p in range (2, 1500): 
    pr = True
    for i in range (2, int (p ** 0.5 + 1)):
        if p & i ==0:
          pr = False
          break
    if pr:
        lst.append(str(p))
for i in b:
    if i in a and len (b)==3:
        s=s+str(a.index(i))
        k=1
    else:
        print('wrong input')
        break
    

if s in lst :
    print(s)
elif k==1: 
    for i in range (11):
        if str(int (s)+i) in lst:
            ql-int (s) +i
            break
    for i in range(1,-11,-1):
        if str(int (s)+i) in lst:
            q2=int(s) + i
            break
    if abs (abs (q1)-int (s)) <abs (abs (q2)-int(s)):
        print (q1)
    else:
        print (q2)
